package org.taobao.ibatiside.core.filemodel;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.PlatformObject;

public abstract class IbatisElement extends PlatformObject {
	protected IbatisElement parent;
	protected List<IbatisElement> children = Collections.EMPTY_LIST;
	public void addChild(IbatisElement element){
		if (children == Collections.EMPTY_LIST){
			children = new ArrayList<IbatisElement>();
		}
		children.add(element);
	}
	public void removeChild(IbatisElement element){
		element.setParent(null);
		children.remove(element);
		
	}
	public List<IbatisElement> getChildren() {
		return children;
	}
	public void setParent(IbatisElement parent) {
		this.parent = parent;
		parent.addChild(this);
		
	}
	public IbatisElement getParent() {
		return parent;
	}
	public abstract IResource  getResource();
}
